package com.lengyue.imakiba.manage;

import java.util.List;

import com.jfinal.core.Controller;
import com.lengyue.imakiba.data.Dict;

public class DictManage extends Controller{
	/**
	 * 取字典类型并根据sort_no排序
	 * @param dictType 字典类型
	 * @param sort 排序：asc、desc
	 * @return
	 */
	public List<Dict> getDictByDictType(String dictType,String sort)
	{
		StringBuffer sql = new StringBuffer();
		sql.append("select * from dict where dict_type_id = ?");
		if("desc".equals(sort.toLowerCase()))
		{
			sql.append(" order by sort_no desc");
		}else if("asc".equals(sort.toLowerCase()))
		{
			sql.append(" order by sort_no asc");
		}
		List<Dict> dicts = Dict.dao.find(sql.toString(), dictType);
		return dicts;
	}
	/**
	 * 取字典类型默认升序
	 * @param dictType 字典类型
	 * @return
	 */
	public List<Dict> getDictByDictType(String dictType)
	{
		String sort = "asc";
		return getDictByDictType( dictType, sort);
	}
}
